package com.jueban.Vo;

import com.jueban.model.ApplyReward;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class ApplyRewardsVo extends ResultVo {

    int offset;
    int pageNumber;
    int pageSize;

    List<ApplyRewardVo> applyRewardVos = new ArrayList<ApplyRewardVo>();

    public ApplyRewardsVo(Page<ApplyReward> applyRewards) {
        setProperties(applyRewards);
    }

    public ApplyRewardsVo() {
    }

    public void setProperties(Page<ApplyReward> applyRewards) {
        pageSize = applyRewards.getSize();
        pageNumber = applyRewards.getTotalPages();
        offset = applyRewards.getNumber();

        for (ApplyReward reward : applyRewards) {
            ApplyRewardVo applyRewardVo = new ApplyRewardVo();
            applyRewardVo.setProperties(reward);
            applyRewardVos.add(applyRewardVo);
        }
    }

    public void setPreviewProperties(Page<ApplyReward> applyRewards){
        pageSize = applyRewards.getSize();
        pageNumber = applyRewards.getTotalPages();
        offset = applyRewards.getNumber();

        for (ApplyReward reward : applyRewards) {
            ApplyRewardVo applyRewardVo = new ApplyRewardVo();
            applyRewardVo.setPreviewProperties(reward);
            applyRewardVos.add(applyRewardVo);
        }
    }

}
